<template>
    <div>
        <el-header style="text-align: center; font-size: 30px">
            <span>健康档案信息</span>
        </el-header>

        <el-table
                :data="tableData"
                border
                style="width: 100%">
            <el-table-column
                    fixed
                    prop="sno"
                    label="学号"
                    width="60">
            </el-table-column>

            <el-table-column
                    prop="sname"
                    label="姓名"
                    width="75">
            </el-table-column>

            <el-table-column
                    prop="sex"
                    label="性别"
                    width="60">
            </el-table-column>

            <el-table-column
                    prop="sage"
                    label="年龄"
                    width="50">
            </el-table-column>

            <el-table-column
                    prop="political_countenance"
                    label="诊断"
                    width="90">
            </el-table-column>

            <el-table-column
                    prop="snation"
                    label="身高"
                    width="60">
            </el-table-column>

            <el-table-column
                    prop="school_system"
                    label="体重"
                    width="60">
            </el-table-column>

            <el-table-column
                    prop="snation"
                    label="胸围"
                    width="60">
            </el-table-column>

            <el-table-column
                    prop="smajor"
                    label="系别"
                    width="90">
            </el-table-column>

            <el-table-column
              prop="political_countenance"
              label="日期"
              width="90">
            </el-table-column>

            <el-table-column>
                    fixed="right"
                    label="操作"
                    width="90">
                <template slot-scope="scope">
                    <el-button @click="edit(scope.row)" type="text" size="small">修改</el-button>
                    <el-button @click="deleteStu(scope.row)" type="text" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                background
                layout="prev, pager, next"
                :page-size="5"
                :total="total"
                @current-change="page">
        </el-pagination>
    </div>
</template>

<script>
    export default {
        methods: {
            deleteStu(row){
                console.log(row.sno)
              this.$axios.delete('http://localhost:8282/StuInformation/deleteById/'+row.sno).then(row=>{
                  this.$message({
                      message: '删除成功!',
                      center: true,
                      type: 'success'
                  });
                  console.log(row)
                  window.location.reload()
              })
            },
            edit(row) {
                this.$router.push({
                    path: '/StudentUpdate',
                    query: {
                        sno:row.sno
                    }
                })
            },
            page(currentPage) {
                this.$axios.get('http://localhost:8282/StuInformation/findAll/'+currentPage+'/6').then(resp=> {
                    this.tableData = resp.data.content
                    this.total = resp.data.totalElements
                })
            }
        },
        created(){
            this.$axios.get('http://localhost:8282/StuInformation/findAll/1/6').then(resp=> {
                this.tableData = resp.data.content
                this.total = resp.data.totalElements
            })
        },

        data() {
                return {
                    total: null,
                    tableData: null,
                }
            }
    }
</script>

<style>

</style>